<template>
  <el-form-item label="频道">
    <el-select clearable placeholder="请选择频道" v-model="channelId" @change="hChange">
      <el-option v-for="channel in channelName" :key="channel.id" :label="channel.name" :value="channel.id"></el-option>
    </el-select>
  </el-form-item>
</template>
<script>
export default {
  name: 'MyChannel',
  data () {
    return {
      channelId: '',
      channelName: []
    }
  },
  methods: {
    async getChannel () {
      try {
        const res = await this.$axios({
          method: 'GET',
          url: '/mp/v1_0/channels'
        })
        console.log(res)
        this.channelName = res.data.data.channels
      } catch (err) {
        console.log(err)
      }
    },
    hChange (val) {
      console.log(val)
      this.$emit('input', val)
    }
  },
  created () {
    this.getChannel()
  }
}
</script>
